﻿






-- 取得当前考勤记录对应信息
CREATE procedure [dbo].[GetCurrentKqjlInfo]
@kh varchar(10),
@kqsj datetime,
@jsdsblsh int
as

select vRyBzInfo.sfzh,vRyBzInfo.xm,vRyBzInfo.xp,bzmc qybmm,RyCa_Info.kh,kbs,fbmc,vRyBzInfo.gz1,vRyBzInfo.lxdh,vRyBzInfo.gh
from vRyBzInfo left join RyCa_Info on(vRyBzInfo.sfzh=RyCa_Info.sfzh and @kqsj between fksj and isnull(cxsj,'2099-12-30'))
left join Ca_Info on(RyCa_Info.kh=Ca_Info.kh)
inner join vRyFbInfo on(vRyFbInfo.sfzh=vRyBzInfo.sfzh)
inner join JsdRyqx_Info on(JsdRyqx_Info.sfzh=vRyBzInfo.sfzh)
inner join Jsdsb_Info on(JsdRyqx_Info.jsdbh=Jsdsb_Info.jsdbh and jsdsblsh=@jsdsblsh)
where cxsj is null and (RyCa_Info.kh=@kh or ryid=cast(@kh as bigint))

select sbbs,sbh,sblx,kzlx,ljlx,jsdsblsh,Jsdsb_Info.jsdbh,Sb_Info.sblsh,sfkqkq,sbbs,Jsdm,case sfkqkq when 0 then '关闭' else '开启' end sfkqkq_desc,sbyt
from Jsdsb_Info 
inner join Sb_Info on (Jsdsb_Info.sblsh=Sb_Info.sblsh)
inner join Jsd_Info on(Jsdsb_Info.jsdbh=Jsd_Info.jsdbh)
where jsdsblsh=@jsdsblsh